package com.guigu.base.controller;


import com.guigu.base.entity.BaseArea;
import com.guigu.base.service.AreaService;
import com.guigu.tms.result.R;
import com.guigu.tms.result.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author TaoLong
 * @since 2021-11-18
 */
@RestController
@RequestMapping("/base/area")
@Api(tags = "行政区域管理")
public class AreaController {

    @Autowired
    private AreaService areaService;


    /**
     * 获取当前订单所属的行政范围
     *
     * @param provinceId
     * @param cityId
     * @param countyId
     * @return
     */
    @ApiOperation("获取当前订单所属的行政范围")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "provinceId", value = "省Id"),
            @ApiImplicitParam(name = "cityId", value = "市Id"),
            @ApiImplicitParam(name = "countyId", value = "县Id")

    })
    @GetMapping("/getAdministrativeScope/{provinceId}/{cityId}/{countyId}")
    public R<BaseArea> getAdministrativeScope(@PathVariable String provinceId,
                                              @PathVariable String cityId,
                                              @PathVariable String countyId) {
        BaseArea baseArea = areaService.getCurrentAdministrativeAreaInformation(provinceId, cityId, countyId);
        return new R<>(ResultCode.SUCCESS_CODE, baseArea);
    }
}

